Skip to content

refactor(cli): replace styleText with picocolors#1950

Closed
liangmiQwQ wants to merge 4 commits into
voidzero-dev:mainfrom
liangmiQwQ:liang/codex/refactor-picocolors-cli
Closed

refactor(cli): replace styleText with picocolors#1950
liangmiQwQ wants to merge 4 commits into
voidzero-dev:mainfrom
liangmiQwQ:liang/codex/refactor-picocolors-cli

Conversation

@liangmiQwQ

@liangmiQwQ liangmiQwQ commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Close #1947

This PR replaces JS CLI uses of node:util styleText with picocolors, matching Rust and Vite side's CI behavior.

It updates create, migrate, terminal, help, editor, agent, and tsconfig prompt formatting, plus the CLI output polish RFC reference.

🤖 Generated with Codex

@netlify

netlify Bot commented Jun 26, 2026

Copy link
Copy Markdown

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit 7db8b56
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a3dfa2b33924700085ac59c

@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 67d810519d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/core/package.json
@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 064251a101

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@@ -1,4 +1,4 @@
import { styleText } from 'node:util';
import colors from 'picocolors';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Badge Preserve non-TTY color suppression

With the default picocolors export, color support is computed from environment variables and treats CI=true as color-capable even when stdout is not a TTY; styleText() previously returned plain text in that same non-TTY CI case unless color was explicitly forced. For invocations such as CI=true vp create ... > log without NO_COLOR, these shared helpers now inject ANSI escapes into captured output, which changes the documented no-behavior-change refactor and can break log/snapshot consumers. Consider creating a local colors wrapper with the previous stream/TTY gating instead of using the default export directly.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does bring a behavior change, but I think it should be treated as an improvement.

In Rust side, we use owo_colors which emits ANSI chars, the same behavior as Vite, who has already used picocolors for a long time. So use default picocolors exports can help create more united mental model.

@liangmiQwQ liangmiQwQ marked this pull request as ready for review June 26, 2026 01:26
@liangmiQwQ liangmiQwQ requested a review from fengmk2 June 26, 2026 01:26
@fengmk2 fengmk2 added test: e2e Auto run e2e tests test: create-e2e Run `vp create` e2e tests labels Jun 26, 2026
@fengmk2

fengmk2 commented Jun 26, 2026

Copy link
Copy Markdown
Member

@liangmiQwQ may be worth adding a small regression snap test to check that imports the JS CLI entry under a Node version older than 20.12, since the original failure happens during module loading rather than command execution.

@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

Well... there are upstream dependencies using styleText (@clack/core), so this PR could not solve Node.js version problem.

So, the only tiny value this PR has left is #1950 (comment), I will modify the PR description, you can decide to close or merge this PR.

[1]> vp run hi
file://<homedir>/code/voidzero-dev/vite-plus/packages/cli/dist/tsconfig-YOTZAtzV.js:8
import { stripVTControlCharacters, styleText } from "node:util";
                                   ^^^^^^^^^
SyntaxError: The requested module 'node:util' does not provide an export named 'styleText'

Node.js v<semver>

@fengmk2

fengmk2 commented Jun 26, 2026

Copy link
Copy Markdown
Member

@liangmiQwQ Just as I expected, after all, many of our dependencies no longer support older versions of Node.js.

@fengmk2 fengmk2 closed this Jun 27, 2026
@liangmiQwQ liangmiQwQ deleted the liang/codex/refactor-picocolors-cli branch June 27, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test: create-e2e Run `vp create` e2e tests test: e2e Auto run e2e tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace node:utils#styleText with picocolors

2 participants